let btnEle = document.querySelector('.btn')
let right = document.querySelector('.header-right')
let header = document.querySelector('.header')

//addEventListener监听事件
btnEle.addEventListener("click", function () {
    const rightClassName = right.getAttribute("class");
    if (rightClassName.indexOf("menu-hover") === -1) {
        right.setAttribute("class", `${rightClassName} menu-hover`);
    } else {
        right.setAttribute("class", rightClassName.replace("menu-hover", ""));
    }
})
//设置当滚动条滚动到固定的地方样式出现变化

    topNavCollapse();
    $(window).scroll(function(){
        topNavCollapse();
    });
    function topNavCollapse(){
        let scrollTop = window.pageYOffset || document.documentElement.scrollTop ||
        document.body.scrollTop;
        if(scrollTop > 50){
            $(".header").addClass("herder-top-collapse");
        }else{
            $(".header").removeClass("herder-top-collapse");
        }
    }

//设置点击跳转事件
function scrollInto(selector) {
    let el = document.querySelector(selector);
    if (el) {
        el.scrollIntoView();
    }
}
